package com.hanxiaozhang.order.entity;

import com.hanxiaozhang.order.constant.OrderTypeEnum;
import com.hanxiaozhang.validation.annotation.EnumRange;
import com.hanxiaozhang.validation.annotation.PriceNotEmpty;
import com.hanxiaozhang.validation.group.CreateGroupValidation;
import com.hanxiaozhang.validation.group.UpdateGroupValidation;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * 〈一句话功能简述〉<br>
 * 〈OrderDTO〉
 *
 * @author hanxinghua
 * @create 2020/7/22
 * @since 1.0.0
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Order {

    private Long id;

    @Valid
    @NotBlank(message = "订单名称不能为空!",groups = {CreateGroupValidation.class, UpdateGroupValidation.class})
    private String orderName;

    @Valid
    @NotBlank(message = "订单编号不能为空!",groups = {UpdateGroupValidation.class})
    private String orderNo;

    @EnumRange(message = "订单类型错误!",enumClass = OrderTypeEnum.class, enumValidMethod ="isValidCode",groups = {CreateGroupValidation.class, UpdateGroupValidation.class} )
    @NotNull(message = "订单类型为空!",groups = {CreateGroupValidation.class, UpdateGroupValidation.class})
    private Integer type;

    private Integer number;

    @PriceNotEmpty(groups = {CreateGroupValidation.class, UpdateGroupValidation.class})
    private BigDecimal price;

}
